// tabBar的data
let tabData = {
  tabIndex: 0, //底部按钮高亮下标
  tabBar: {
    custom: true,
    color: "#5F5F5F",
    selectedColor: "#07c160",
    backgroundColor: "#F7F7F7",
    list: []
  }
}

// 更新菜单
const updateRole = (that, type) => {
  //这里设置权限（分2种权限，权限1显示1，2，3；权限2显示4，5，6，7；）
  if (type === '0') {
    tabData.tabBar.list = [{
        "pagePath": "pages/servicelIst/index",
        "text": "首页",
        "iconPath": "./assets/image/tarbar/home.png",
        "selectedIconPath": "./assets/image/tarbar/homed.png"
      },
      {
        "pagePath": "pages/orderList/index",
        "text": "订单列表",
        "iconPath": "./assets/image/tarbar/message.png",
        "selectedIconPath": "./assets/image/tarbar/messaged.png"
      },
      {
        "pagePath": "pages/user/index",
        "text": "我的",
        "iconPath": "./assets/image/tarbar/user.png",
        "selectedIconPath": "./assets/image/tarbar/usered.png"
      }
    ]
  } else if (type === '1') {
    tabData.tabBar.list = [{
      "pagePath": "pagesDoctor/docterIndex/index",
      "text": "我的",
      "iconPath": "./assets/image/tarbar/user.png",
      "selectedIconPath": "./assets/image/tarbar/usered.png"
    }, ]
  }
  updateTab(that);
}

// 更新底部高亮
const updateIndex = (that, index) => {
  tabData.tabIndex = index;
  updateTab(that);
}

// 更新Tab状态
const updateTab = (that) => {
  if (typeof that.getTabBar === 'function' && that.getTabBar()) {
    that.getTabBar().setData(tabData);
  }
}

// 将可调用的方法抛出让外面调用
module.exports = {
  updateRole,
  updateTab,
  updateIndex,
  tabBar: tabData.tabBar.list
}